<?php $this->load->view('base/header'); ?>

<link rel="stylesheet" media="screen" href="<?php echo base_url() . 'css/jquery.datatable.gui.css' ?>"/>
<link rel="stylesheet" media="screen" href="<?php echo base_url() . 'css/jquery-ui-1.8.14.custom.css' ?>"/>
<link rel="stylesheet" media="screen" href="<?php echo base_url() . 'css/table.css' ?>"/>

<script type="text/javascript" src="<?php echo base_url() . 'js/jquery-ui-1.8.14.custom.min.js' ?>"></script>
<script type="text/javascript" src="<?php echo base_url() . 'js/jquery.dataTables.js' ?>"></script>
<script type="text/javascript" src="<?php echo base_url() . 'js/jquery.formatCurrency-1.4.0.js' ?>"></script>

<script type="text/javascript" src="<?php echo base_url() . 'js/br-03/peminjaman.js' ?>"></script>
<script type="text/javascript" src="<?php echo base_url() . 'js/br-03/anggota.js' ?>"></script>

<script type="text/javascript">
    function changeBunga()
    {
        var userinput = document.getElementById("TIPE_KREDIT").value;
        if (userinput==1)
            document.forms['FORM_PINJAMAN'].BUNGA.value = document.getElementById("bunga_1").value;
        else if (userinput==2)
            document.forms['FORM_PINJAMAN'].BUNGA.value = document.getElementById("bunga_2").value;
        else
            document.forms['FORM_PINJAMAN'].BUNGA.value = document.getElementById("bunga_3").value;
    }
    function calAngsur(){
        var jumlah = document.getElementById("MAX_PIUTANG").value;
        var lama = document.getElementById("MAX_CICIL").value;
        var bunga = document.getElementById("BUNGA").value;
        var angsur = jumlah/lama + ((bunga/100)*jumlah);
        document.forms['FORM_PINJAMAN'].ANGSURAN_PERBULAN.value = angsur;
    }
</script>

<section>
    <div class="container_8 clearfix">
        <section class="main-section grid_8">
            <div class="main-content">
                <header>
                    <h2>Permintaan Pelayanan</h2>
                </header>
                <section class="container_6 clearfix">
                    <div class="grid_6">

                        <section class="clearfix">
                            <form class="form" id="FORM_PINJAMAN" method="post">

                                <div style="float: left;">
                                    <div class="clearfix">
                                        <label>Nomor Anggota<small></small></label>
                                        <input type="text" name="ID_ANGGOTA" id="ID_ANGGOTA" size="4"/>
                                    </div>
                                    <div class="clearfix">
                                        <label>Nama Anggota <small></small></label>
                                        <input type="text" name="NAMA_ANGGOTA" id="NAMA_ANGGOTA" disabled />
                                    </div>
                                </div>
                                <div style="float: left;">
                                    <div class="clearfix">
                                        <label>Divisi <small></small></label>
                                        <input type="text" name="NAMA_DIVISI" id="NAMA_DIVISI" disabled />
                                    </div>
                                    <div class="clearfix">
                                        <label>Alamat <small> Rumah</small></label>
                                        <input type="text" name="ALAMAT" id="ALAMAT" disabled />
                                    </div>
                                </div>
                                <dir style="clear: both"></dir>
                                <hr/>

                                <div style="float: left;">
                                    <div class="clearfix">
                                        <label>Jenis Pelayanan<small></small></label>
                                        <select id="JENIS_PELAYANAN" name="JENIS_PELAYANAN">
                                            <option value="1">Simpan Pinjam</option>
                                            <option value="0">Jual Beli</option>
                                        </select>
                                    </div>
                                    <div class="clearfix" id="TIPE_KREDIT_DIV">
                                        <label>Tipe Pinjaman<small></small></label>
                                        <select id="TIPE_KREDIT" name="TIPE_KREDIT">
                                            <?php foreach ($Kredit->result() as $row): ?>
                                            <option value="<?php echo $row->ID_JENIS_KREDIT ?>"><?php echo $row->NAMA_KREDIT ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                    </div>
                                    <div class="clearfix" id="KODE_USAHA_DIV">
                                        <label>Peruntukan<small></small></label>
                                        <select id="KODE_USAHA" name="KODE_USAHA">
                                            <?php foreach ($Usaha->result() as $row): ?>
                                            <option value="<?php echo $row->KODE_USAHA ?>"><?php echo $row->URAIAN_USAHA ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                    </div>
                                    <div class="clearfix">
                                        <label>Tanggal Kebutuhan<small>yyyy-mm-dd</small></label>
                                        <input type="date" name="TANGGAL_PINJAM" id="TANGGAL_PINJAM" />
                                    </div>
                                    <div class="clearfix">
                                        <label>Keterangan<small></small></label>
                                        <textarea name="KETERANGAN" id="KETERANGAN" ></textarea>
                                    </div>
                                    <button class="button button-gray" type="submit" id="preview_skema" style="margin-left: 100px;"><span class="accept"></span>Lihat Simulasi</button>
                                </div>

                                <input type="hidden" name="BUNGA" id="BUNGA" value=""/>

                                <div style="float: left;">
                                    
                                    <div class="clearfix">
                                        <label><label id="LABEL_MAX_PIUTANG">Jumlah</label><small><label id="RULE_MAX_PIUTANG" class="currency"></label></small></label>
                                        <input type="text" name="MAX_PIUTANG" id="MAX_PIUTANG" maxlength="15" class="currency"/>
                                    </div>

                                    <div class="clearfix">
                                        <label>Jangka Waktu<small><label id="RULE_MAX_CICIL"></label></small></label>
                                        <input type="text" name="MAX_CICIL" id="MAX_CICIL" maxlength="2" size="2"/>
                                    </div>

                                    <div id="JUAL_BELI_MODE">
                                        <div class="clearfix">
                                            <label>Total Margin<small></small></label>
                                            <input type="text" name="MARGIN" id="MARGIN" maxlength="14" class="currency"/>
                                        </div>
                                    </div>

                                </div>
                                <div style="clear: both;"></div>

                                <div id="SKEMA_ANGSURAN"style="margin: 20px 0 0 0;">
                                    <h3>Simulasi Kewajiban</h3>
                                    <table id="angsuran_table" style="width:90%;" class="detail_table">
                                        <thead>
                                            <tr>
                                                <td>Kewajiban Ke</td>
                                                <td>Cicilan Pokok</td>
                                                <td>Margin</td>
                                                <td>Kewajiban / Bulan</td>
                                                <td>Sisa Kewajiban</td>
                                            </tr>
                                        </thead>
                                        <tbody>

                                        </tbody>
                                        <tfoot>

                                        </tfoot>
                                    </table>
                                </div>

                                <div class="action clearfix" style="margin-top: 30px;">
                                    <button class="button button-gray" type="submit" id="ADD"><span class="accept"></span>Simpan</button>
                                    <button class="button button-gray" type="reset"><span class="bin"></span>Batal</button>
                                </div>
                            </form>
                        </section>
                    </div>
                </section>
            </div>

    </div>
</section>
<div id="anggota_dialog">
    <table id="anggota_table" width="100%" class="datatable">
        <thead>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
<?php $this->load->view('base/footer'); ?>